﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Mvc;
using System.Web.Security;
using OMS.OMSService;

namespace OMS.Models
{
    public class FullOrderModelView
    {
        public FullOrderModelView()
        {
            Order = new OrderModelView();
            CreditCard = new CreditCardModelView();
        }

        public FullOrderModelView(OrderModelView order, CreditCardModelView card)
        {
            Order = order;
            CreditCard = card;
        }

        public OrderModel GetOrderModel()
        {
            OrderModel orderModel = new OrderModel
            {
                OrderNumber = Order.OrderNumber,
                Status = Order.Status,
                TotalPrice = Order.TotalPrice,
                DateOfOrdering = Order.DateOfOrdering,
                PrefDeliveryDate = Order.PrefDate,
                DeliveryDate = Order.DeliveryDate,
                MerchId = Order.Asignee,
                Card = this.GetCreditCard(),
                CustomerIdSpecified = true,
                DateOfOrderingSpecified = true,
                DeliveryDateSpecified = true,
                IdSpecified = true,
                MerchIdSpecified = true,
                PrefDeliveryDateSpecified = true,
                TotalPriceSpecified = true
            };
            return orderModel;
        }

        public CreditCardModel GetCreditCard()
        {
            CreditCardModel creditCard = new CreditCardModel
            {
                _Type = CreditCard._Type,
                Number = CreditCard.Number,
                Cv2 = CreditCard.Cv2,
                ExpiryDate = CreditCard.ExpiryDate,
                StartDate = CreditCard.StartDate,
                IssueNumber = CreditCard.IssueNumber,
                Cv2Specified = true,
                ExpiryDateSpecified = true,
                IdSpecified = true,
                StartDateSpecified = true
            };
            return creditCard;
        }

        public CreditCardModelView CreditCard { get; set; }

        public OrderModelView Order { get; set; }
    }
}